<?
//Mail 0.0.3
class mail{
    private $to = '';
    private $subject = '';
    private $msg = '';
    private $headers = '';
    //Create message
    public function __construct($to, $fromName, $from, $subject, $msg, $cc='', $bcc=''){
        //Data validation
        $to=data::email($to);
        $from=data::email($from);
        $fromName=data::html_view($fromName);
        $subject=data::html_view($subject);
        $msg=data::safe($msg);
        $cc=data::email($cc);
        $bcc=data::email($bcc);
        //Creating vars
        $this->to=$to;
        $this->subject=$subject;
        $this->msg=$msg;
        $this->headers = "From: \"".$fromName."\" <".$from.">\n";
        if($cc) $this->headers.= "CC: ".$cc."\n";
        if($bcc) $this->headers.= "BCC: ".$bcc."\n";
        $this->headers.= "Content-type: text/html; charset=\"utf-8\"";
    }
    //Send message
    public function send(){
        if(mail($this->to, $this->subject, $this->msg, $this->headers)){
            return true;
        }
        else{
            return false;
        } 
    }
    //Get value
    public function __get($key){
        return $this->$key;
    }
    //Set value
    public function __set($key, $val){
        $this->$key=$val;
    }
}
?>
